package cn.aspect.util;

import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

public class IdUtils {


    @AllArgsConstructor
    @Getter
    private enum SNOWFLAKE_SINGLETON {
        // workId:终端ID,
        // dataCenterId:数据中心ID
        INSTANCE(IdUtil.getSnowflake(1, 1));
        private Snowflake snowflake;
    }

    /**
     * 获取雪花Id
     *
     * @return
     */
    public static Long getSnowflakeId() {
        return SNOWFLAKE_SINGLETON.INSTANCE.getSnowflake().nextId();
    }

    public static Snowflake getSnowflake(){
        return SNOWFLAKE_SINGLETON.INSTANCE.getSnowflake();
    }
}
